/**
 * Dear programmer:
 * When I wrote this code, only god and I knew how it worked.
 * Now, only god knows it!
 *
 * @author: Pegasus  Date: 2019-02-13 Time: 23:07
 */
import {
    RetrieveRoomMSG,
    RetrieveRoomMSGByRoom,
    GetScurryDefault,
    SetRoomOOOS,
    RetrieveLogRecord,
    RetrieveHoLose,
    HoLoseAdd,
    Retrieveroomooos,
    HousekeepingSweepSetStatus,
    SaveScurryOrder,
    GetWHSKDict,
    SaveRoomClean,
    SaveSearchMiss,
    SaveGuestService,
    SaveGoodsService,
    RetrieveRoommates,
    RetrieveGuestLedger
} from "./Actions"
import {FetchStatus} from "../../../configuration/RequestConfiguration"

/**
 * 获取即时维修单状态
 * @param state
 * @param action
 * @returns {{fetchStatus: *}}
 */
export const onRetrieveRoomMSG = (state = {}, action) => {
  switch (action.type) {
    case RetrieveRoomMSG: {
      switch (action.status) {
        case FetchStatus.Start: {
          return {...state, fetchStatus: action.status}
        }
        case FetchStatus.Success: {
          return {...action.json, fetchStatus: action.status}
        }
        default: {
          return {...state, fetchStatus: action.status}
        }
      }
    }
  }
  return state
};

export const onRetrieveRoomMSGByRoom = (state = {}, action) => {
    switch (action.type) {
        case RetrieveRoomMSGByRoom: {
            switch (action.status) {
                case FetchStatus.Start: {
                    return {...state, fetchStatus: action.status}
                }
                case FetchStatus.Success: {
                    return {...action.json, fetchStatus: action.status}
                }
                default: {
                    return {...state, fetchStatus: action.status}
                }
            }
        }
    }
    return state
};

export const onRetrieveRoommates = (state = {}, action) => {
    switch (action.type) {
        case RetrieveRoommates: {
            switch (action.status) {
                case FetchStatus.Start: {
                    return {...state, fetchStatus: action.status}
                }
                case FetchStatus.Success: {
                    return {...action.json, fetchStatus: action.status}
                }
                default: {
                    return {...state, fetchStatus: action.status}
                }
            }
        }
    }
    return state
};

export const onRetrieveGuestLedger = (state = {}, action) => {
    switch (action.type) {
        case RetrieveGuestLedger: {
            switch (action.status) {
                case FetchStatus.Start: {
                    return {...state, fetchStatus: action.status}
                }
                case FetchStatus.Success: {
                    return {...action.json, fetchStatus: action.status}
                }
                default: {
                    return {...state, fetchStatus: action.status}
                }
            }
        }
    }
    return state
};

export const onGetScurryDefault= (state = {}, action) => {
    switch (action.type) {
        case GetScurryDefault: {
            switch (action.status) {
                case FetchStatus.Start: {
                    return {...state, fetchStatus: action.status}
                }
                case FetchStatus.Success: {
                    return {...action.json, fetchStatus: action.status}
                }
                default: {
                    return {...state, fetchStatus: action.status}
                }
            }
        }
    }
    return state
};


export const onSetRoomOOOS= (state = {}, action) => {
    switch (action.type) {
        case SetRoomOOOS: {
            switch (action.status) {
                case FetchStatus.Start: {
                    return {...state, fetchStatus: action.status}
                }
                case FetchStatus.Success: {
                    return {...action.json, fetchStatus: action.status}
                }
                default: {
                    return {...state, fetchStatus: action.status}
                }
            }
        }
    }
    return state
};

export const onRetrieveLogRecord= (state = {}, action) => {
    switch (action.type) {
        case RetrieveLogRecord: {
            switch (action.status) {
                case FetchStatus.Start: {
                    return {...state, fetchStatus: action.status}
                }
                case FetchStatus.Success: {
                    return {...action.json, fetchStatus: action.status}
                }
                default: {
                    return {...state, fetchStatus: action.status}
                }
            }
        }
    }
    return state
};



export const onRetrieveHoLose= (state = {}, action) => {
    switch (action.type) {
        case RetrieveHoLose: {
            switch (action.status) {
                case FetchStatus.Start: {
                    return {...state, fetchStatus: action.status}
                }
                case FetchStatus.Success: {
                    return {...action.json, fetchStatus: action.status}
                }
                default: {
                    return {...state, fetchStatus: action.status}
                }
            }
        }
    }
    return state
};

export const onHoLoseAdd= (state = {}, action) => {
    switch (action.type) {
        case HoLoseAdd: {
            switch (action.status) {
                case FetchStatus.Start: {
                    return {...state, fetchStatus: action.status}
                }
                case FetchStatus.Success: {
                    return {...action.json, fetchStatus: action.status}
                }
                default: {
                    return {...state, fetchStatus: action.status}
                }
            }
        }
    }
    return state
};




export const onRetrieveroomooos= (state = {}, action) => {
    switch (action.type) {
        case Retrieveroomooos: {
            switch (action.status) {
                case FetchStatus.Start: {
                    return {...state, fetchStatus: action.status}
                }
                case FetchStatus.Success: {
                    return {...action.json, fetchStatus: action.status}
                }
                default: {
                    return {...state, fetchStatus: action.status}
                }
            }
        }
    }
    return state
};

export const onHousekeepingSweepSetStatus= (state = {}, action) => {
    switch (action.type) {
        case HousekeepingSweepSetStatus: {
            switch (action.status) {
                case FetchStatus.Start: {
                    return {...state, fetchStatus: action.status}
                }
                case FetchStatus.Success: {
                    return {...action.json, fetchStatus: action.status}
                }
                default: {
                    return {...state, fetchStatus: action.status}
                }
            }
        }
    }
    return state
};


export const onSaveScurryOrder= (state = {}, action) => {
    switch (action.type) {
        case SaveScurryOrder: {
            switch (action.status) {
                case FetchStatus.Start: {
                    return {...state, fetchStatus: action.status}
                }
                case FetchStatus.Success: {
                    return {...action.json, fetchStatus: action.status}
                }
                default: {
                    return {...state, fetchStatus: action.status}
                }
            }
        }
    }
    return state
};

export const onGetWHSKDict= (state = {}, action) => {
    switch (action.type) {
        case GetWHSKDict: {
            switch (action.status) {
                case FetchStatus.Start: {
                    return {...state, fetchStatus: action.status}
                }
                case FetchStatus.Success: {
                    return {...action.json, fetchStatus: action.status}
                }
                default: {
                    return {...state, fetchStatus: action.status}
                }
            }
        }
    }
    return state
};

// 住房打扫
export const onSaveRoomClean= (state = {}, action) => {
    switch (action.type) {
        case SaveRoomClean: {
            switch (action.status) {
                case FetchStatus.Start: {
                    return {...state, fetchStatus: action.status}
                }
                case FetchStatus.Success: {
                    return {...action.json, fetchStatus: action.status}
                }
                default: {
                    return {...state, fetchStatus: action.status}
                }
            }
        }
    }
    return state
};

// 住房打扫
export const onSaveSearchMiss= (state = {}, action) => {
    switch (action.type) {
        case SaveSearchMiss: {
            switch (action.status) {
                case FetchStatus.Start: {
                    return {...state, fetchStatus: action.status}
                }
                case FetchStatus.Success: {
                    return {...action.json, fetchStatus: action.status}
                }
                default: {
                    return {...state, fetchStatus: action.status}
                }
            }
        }
    }
    return state
};

// 客人催服务
export const onSaveGuestService= (state = {}, action) => {
    switch (action.type) {
        case SaveGuestService: {
            switch (action.status) {
                case FetchStatus.Start: {
                    return {...state, fetchStatus: action.status}
                }
                case FetchStatus.Success: {
                    return {...action.json, fetchStatus: action.status}
                }
                default: {
                    return {...state, fetchStatus: action.status}
                }
            }
        }
    }
    return state
};

// 物品/服务
export const onSaveGoodsService= (state = {}, action) => {
    switch (action.type) {
        case SaveGoodsService: {
            switch (action.status) {
                case FetchStatus.Start: {
                    return {...state, fetchStatus: action.status}
                }
                case FetchStatus.Success: {
                    return {...action.json, fetchStatus: action.status}
                }
                default: {
                    return {...state, fetchStatus: action.status}
                }
            }
        }
    }
    return state
};





